package cn.gan.loveofsoul.entity;

import cn.gan.loveofsoul.entity.vo.UserVO;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author ganwh
 * @since 2023-10-13
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "user_id", type = IdType.AUTO)
    private Integer userId;

    private String wxOpenId;

    private String userName;

    private String avatarUrl;

    private Integer sex;

    private Integer status;

    private Integer flag;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    public User(Integer userId, String wxOpenId, String userName, String avatarUrl, Integer sex, Integer flag) {
        this.userId = userId;
        this.wxOpenId = wxOpenId;
        this.userName = userName;
        this.avatarUrl = avatarUrl;
        this.sex = sex;
        this.flag = flag;
    }

    public static UserVO convert2UserVO(User user) {
        UserVO userVO = new UserVO();
        BeanUtil.copyProperties(user, userVO);
        return userVO;
    }

    public static User userVOConvert2User(UserVO userVO) {
        User user = new User();
        BeanUtil.copyProperties(userVO, user);
        return user;
    }
}
